package com.ruiysoft.service.logistics;

import com.ruiysoft.controller.logistics.vo.ExpressInfo;
import com.ruiysoft.entity.logistics.APILogisticsMessage;
import com.ruiysoft.entity.logistics.LogisticsException;
import com.ruiysoft.entity.logistics.LogisticsShopApiConf;
import com.ruiysoft.entity.logistics.LogisticsSubscribe;
import com.ruiysoft.pub.core.Result;

import java.util.List;
import java.util.Optional;

public interface ILogisticsQueryService {

    /**
     * 验证快递单号与快递公司是否匹配
     * @param shopID
     * @param expressNO
     * @param unionCode
     * @return
     * @throws LogisticsException
     */
    boolean validate(Long shopID,String expressNO,String unionCode)throws LogisticsException;

    /**
     * 订阅一个物流信息，系统内部使用。
     * @param shopID        店铺
     * @param subscriber    订阅者
     * @param subscribeID   订阅主体id
     * @param expressNO     快递单号
     * @param expressCom    快递公司编码
     * @return
     * @throws LogisticsException
     */
    Result<Void> subscribe(Long shopID, String subscriber, String subscribeID, String expressNO, String expressCom)throws LogisticsException;
    List<LogisticsSubscribe> getSubscribe(String expressNO, String expressCom);
    ExpressInfo revertExpressComByENO(Long shopID, String expressNO)throws LogisticsException;

    /**
     * 一般情况下用于快递查询服务商的回调
     * @param apiSupplier 快递查询服务商
     * @param shopID    微店主键
     * @param logisticsMessage  物流信息
     */
    void updateLogistics(String apiSupplier,Long shopID,APILogisticsMessage logisticsMessage);

    //public LogisticsFinalState queryLogisticsFinalState(Long shopID, String expressNO, Optional<String> unionCode) throws LogisticsException;

    /**
     * 推荐使用 queryLogisticsMessage(Long shopID, String expressNO,String expressCom) 进行查找
     * @param shopID
     * @param expressNO
     * @return
     * @throws LogisticsException
     */
    APILogisticsMessage queryLogisticsMessage(Long shopID, String expressNO) throws LogisticsException;

    /**
     * 推荐使用此方法，进行精确快递公司+快递单查询
     * @param shopID
     * @param expressNO
     * @param expressCom
     * @return
     * @throws LogisticsException
     */
    APILogisticsMessage queryLogisticsMessage(Long shopID, String expressNO,String expressCom) throws LogisticsException;

    /**
     * 获取店铺可用的"快递配置"
     * @param shopID
     * @return
     */
    LogisticsShopApiConf getUseableLogisticsApiConf4Shop(Long shopID);

    /**
     * 查询快递是否已经签收
     * @param shopID
     * @param expressNO
     * @param expressCom
     * @return
     * @throws LogisticsException
     */
    boolean isExpressChecked(Long shopID, String expressNO, String expressCom)throws LogisticsException;
}
